package com.aspose.cells;

class zcdb {
   byte[] c;
   protected int d;

   protected zcdb() {
   }

   zcdb(int var1) {
      this.d = var1;
   }

   zcdb(int var1, int var2) {
      this.d = var1;
      this.c = com.aspose.cells.b.a.zc.a(var2);
   }

   void a(com.aspose.cells.b.a.d.zm var1) throws Exception {
      byte[] var2 = new byte[8];
      byte var3 = 0;
      int var4 = a(var2, var3, this.d);
      if (this.c != null) {
         var4 = a(var2, var4, this.c.length);
         var1.b(var2, 0, var4);
         var1.b(this.c, 0, this.c.length);
      } else {
         var1.b(var2, 0, var4 + 1);
      }

   }

   static void a(int var0, com.aspose.cells.b.a.d.zm var1) throws Exception {
      byte[] var2 = new byte[5];
      byte var3 = 0;
      int var4 = a(var2, var3, var0);
      var1.b(var2, 0, var4 + 1);
   }

   static void a(int var0, int var1, int var2, com.aspose.cells.b.a.d.zm var3) throws Exception {
      byte[] var4 = new byte[7];
      byte var5 = 0;
      int var6 = a(var4, var5, var0);
      var4[var6] = (byte)var2;
      ++var6;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, var4, var6, var2);
      var6 += var2;
      var3.b(var4, 0, var6);
   }

   private static int a(byte[] var0, int var1, int var2) {
      while(true) {
         int var3 = var2 % 128;
         int var4 = var2 / 128;
         if (var4 <= 0) {
            var0[var1++] = (byte)var3;
            return var1;
         }

         var3 |= 128;
         var0[var1++] = (byte)var3;
         var2 = var4;
      }
   }

   protected int a(String var1, int var2) {
      int var3 = var2;
      int var4;
      if (var1 == null) {
         for(var4 = 0; var4 < 4; ++var4) {
            this.c[var3++] = -1;
         }
      } else if (var1.length() == 0) {
         for(var4 = 0; var4 < 4; ++var4) {
            this.c[var3++] = 0;
         }
      } else {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var1.length()), 0, this.c, var2, 4);
         var3 = var2 + 4;
         byte[] var5 = Encoding.getUnicode().a(var1);
         System.arraycopy(var5, 0, this.c, var3, var5.length);
         var3 += var5.length;
      }

      return var3;
   }

   protected void a(DateTime var1, int var2) {
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1.getYear()), 0, this.c, var2, 2);
      this.c[var2 + 2] = (byte)var1.getMonth();
      this.c[var2 + 3] = (byte)var1.getDay();
      this.c[var2 + 4] = (byte)var1.getHour();
      this.c[var2 + 5] = (byte)var1.getMinute();
      this.c[var2 + 6] = (byte)var1.getSecond();
      int var3 = var1.getDayOfWeek();
      if (var3 == 0) {
         var3 = 7;
      }

      this.c[var2 + 7] = (byte)var3;
   }

   static void a(byte[] var0, int var1, zakp var2, int var3, Workbook var4) {
      switch(var2.b()) {
      case 0:
      case 1:
         var0[var1 + 1] = (byte)var3;
         return;
      case 2:
         var0[var1] = 4;
         break;
      case 3:
         var0[var1] = 3;
         var0[var1 + 1] = (byte)var2.d();
         break;
      case 4:
         var0[var1] = 6;
         var0[var1 + 1] = (byte)var2.d();
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a((short)((int)(var2.f() * 32767.0D))), 0, var0, var1 + 2, 2);
      int var5 = var2.c(var4);
      var0[var1 + 4] = (byte)((var5 & 16711680) >> 16);
      var0[var1 + 5] = (byte)((var5 & '\uff00') >> 8);
      var0[var1 + 6] = (byte)(var5 & 255);
      var0[var1 + 7] = -1;
   }
}
